689dd9ce6bf5a4659325aeb7d9c265468202822f,opennms-dao/src/test/java/org/opennms/netmgt/dao/support/FindTopLevelResourcesTest.java,FindTopLevelResourcesTest,execute_testFindTopLevelResources_hybridNodes,#boolean#,271
Before Change
n1.addIpInterface(ip1);
nodes.add(n1);
OnmsNode n2 = new OnmsNode(); // requisitioned node
n2.setId(2);
n2.setLabel("node2");
n2.setForeignSource("Junit");
n2.setForeignId("node2");
OnmsIpInterface ip2 = new OnmsIpInterface();
ip2.setId(12);
ip2.setIpAddress(InetAddressUtils.addr("10.0.0.2"));
ip2.setNode(n2);
n2.addIpInterface(ip2);
nodes.add(n2);
expect(m_dataCollectionConfigDao.getLastUpdate()).andReturn(new Date(System.currentTimeMillis())).times(3);
expect(m_dataCollectionConfigDao.getConfiguredResourceTypes()).andReturn(new HashMap<String, ResourceType>());
expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(n1.getId())).andReturn(new ArrayList<LocationMonitorIpInterface>(0));
if (storeByForeignSource) {
expect(m_nodeDao.findByForeignId(n2.getForeignSource(), n2.getForeignId())).andReturn(n2).times(1);
} else {
expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(n2.getId())).andReturn(new ArrayList<LocationMonitorIpInterface>(0));
}
expect(m_nodeDao.get(n1.getId())).andReturn(n1).times(2); // TODO ResponseTimeResourceType is the responsible for this.
expect(m_nodeDao.get(n2.getId())).andReturn(n2).times(2); // TODO ResponseTimeResourceType is the responsible for this.
expect(m_nodeDao.findAll()).andReturn(nodes);
File snmpDir = m_fileAnticipator.tempDir("snmp");
File node1Dir = m_fileAnticipator.tempDir(snmpDir, n1.getId().toString());
m_fileAnticipator.tempFile(node1Dir, "foo" + RrdUtils.getExtension());
if (storeByForeignSource) {
File fsDir = m_fileAnticipator.tempDir(snmpDir, "fs");
File node2fsDir = m_fileAnticipator.tempDir(fsDir, n2.getForeignSource());
File node2Dir = m_fileAnticipator.tempDir(node2fsDir, n2.getForeignId());
m_fileAnticipator.tempFile(node2Dir, "foo" + RrdUtils.getExtension());
} else {
File node2Dir = m_fileAnticipator.tempDir(snmpDir, n2.getId().toString());
m_fileAnticipator.tempFile(node2Dir, "foo" + RrdUtils.getExtension());
}
File responseDir = m_fileAnticipator.tempDir("response");
After Change
OnmsNode n1 = createNode(1, "node1", null, null, "10.0.0.1"); // Discovered node on the DB with RRD Data
nodes.add(n1);
OnmsNode n2 = createNode(2, "node2", "Junit", "node2", "10.0.0.2"); // Requisitioned node on the DB with RRD Data
nodes.add(n2);
OnmsNode n3 = createNode(3, "node3", null, null, "10.0.0.3"); // Discovered node on the DB with No RRD Data
nodes.add(n3);
OnmsNode n4 = createNode(4, "node4", "Junit", "node4", "10.0.0.4"); // Requisitioned node on the DB with RRD Data
nodes.add(n4);
expect(m_dataCollectionConfigDao.getLastUpdate()).andReturn(new Date(System.currentTimeMillis())).times(3);
expect(m_dataCollectionConfigDao.getConfiguredResourceTypes()).andReturn(new HashMap<String, ResourceType>());
expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(n1.getId())).andReturn(new ArrayList<LocationMonitorIpInterface>(0));
if (storeByForeignSource) {
expect(m_nodeDao.findByForeignId(n2.getForeignSource(), n2.getForeignId())).andReturn(n2).times(1);
} else {
expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(n2.getId())).andReturn(new ArrayList<LocationMonitorIpInterface>(0));
}
expect(m_nodeDao.get(n1.getId())).andReturn(n1).times(2); // TODO ResponseTimeResourceType is the responsible for this.
expect(m_nodeDao.get(n2.getId())).andReturn(n2).times(2); // TODO ResponseTimeResourceType is the responsible for this.
expect(m_nodeDao.findAll()).andReturn(nodes);
File snmpDir = m_fileAnticipator.tempDir("snmp");
File featureDir = m_fileAnticipator.tempDir(snmpDir, "fs");
File fsDir = m_fileAnticipator.tempDir(featureDir, "Junit");
// RRD Directory for n1
File node1Dir = m_fileAnticipator.tempDir(snmpDir, n1.getId().toString());
m_fileAnticipator.tempFile(node1Dir, "foo" + RrdUtils.getExtension());
// RRD Directory for n2
File node2Dir = null;
if (storeByForeignSource) {
node2Dir = m_fileAnticipator.tempDir(fsDir, n2.getForeignId());
} else {
node2Dir = m_fileAnticipator.tempDir(snmpDir, n2.getId().toString());
}
m_fileAnticipator.tempFile(node2Dir, "foo" + RrdUtils.getExtension());
// RRD Directory for an orphan discovered node
m_fileAnticipator.tempFile(m_fileAnticipator.tempDir(snmpDir, "100"), "foo" + RrdUtils.getExtension());
// RRD Directory for an orphan requisitioned node
File orphanDir = null;
if (storeByForeignSource) {
orphanDir = m_fileAnticipator.tempDir(fsDir, "orphan_node");
} else {
orphanDir = m_fileAnticipator.tempDir(snmpDir, "101");
}
m_fileAnticipator.tempFile(orphanDir, "foo" + RrdUtils.getExtension());
File responseDir = m_fileAnticipator.tempDir("response");
File ip1Dir = m_fileAnticipator.tempDir(responseDir, n1.getIpInterfaces().iterator().next().getIpAddress().getHostAddress());
m_fileAnticipator.tempFile(ip1Dir, "foo" + RrdUtils.getExtension());
File ip2Dir = m_fileAnticipator.tempDir(responseDir, n2.getIpInterfaces().iterator().next().getIpAddress().getHostAddress());
m_fileAnticipator.tempFile(ip2Dir, "foo" + RrdUtils.getExtension());
m_easyMockUtils.replayAll();